﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using CaiBaby.Common;
using CaiBaby.Entity;

namespace CaiBaby.DAL
{
    /// <summary>
    /// 在线记事本数据访问层
    /// </summary>
    public class NoteBook
    {
        /// <summary>
        /// 更新记事本
        /// </summary>
        /// <param name="noteBookInfo">记事本实体</param>
        /// <returns>返回是否成功</returns>
        public bool Update(NoteBookInfo noteBookInfo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("UPDATE nb_NoteBook SET ");
            strSql.Append("Contents=@Contents,ChangeTime=@ChangeTime ");
            strSql.Append("WHERE UId=@UId ");
            SqlParameter[] parameters = {
					new SqlParameter("@UId", SqlDbType.Int,4),
					new SqlParameter("@Contents", SqlDbType.VarChar,1024),
					new SqlParameter("@ChangeTime", SqlDbType.DateTime)};
            parameters[0].Value = noteBookInfo.UId;
            parameters[1].Value = noteBookInfo.Contents;
            parameters[2].Value = noteBookInfo.ChangeTime;

            int rows = SQLHelper.ExecuteSql(ConfigHelper.CaiBabyDBConnStr, CommandType.Text, strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
